use std::collections::HashMap;

pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let dic = 
    HashMap::from([(0,'0'),(1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5'),(6,'6'),(7,'7'),(8,'8'),(9,'9'),(10,'a'),(11,'b'),(12,'c'),(13,'d'),(14,'e'),(15,'f')]);

    let s_vec:Vec<&str>= num_str.split("(").collect();
    let mut number = s_vec[0].parse::<u32>().unwrap();
    let origin_  = s_vec[1].to_string().chars().take(s_vec[1].to_string().chars().count()-1).collect::<String>().parse::<u32>().unwrap();
    let mut temp = 0;
    let mut e = 1;
    while number!=0{
        temp+=e*(number%10);
        number /=10;
        e*= origin_;
    }
    let mut result = String::from("");
    while temp!=0{
        let remaider = temp%to_base;
        result.push(dic[&remaider]);
        temp/=to_base;
    }
    result = result.chars().rev().collect();
    println!("{:?}", result);
    result
}
